package com.hbdl.web.sys.service;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageInfo;
import com.hbdl.common.base.ServiceMybatis;
import com.hbdl.common.mybatis.dao.MybatisDaoUtil;
import com.hbdl.common.utils.ResultUtil;
import com.hbdl.common.utils.TreeUtils;
import com.hbdl.web.sys.model.Resources;

@SuppressWarnings({ "rawtypes", "unchecked" })
@Service
public class SysResourceService extends ServiceMybatis<Resources> {

	private MybatisDaoUtil<Map> dao = new MybatisDaoUtil<Map>(Map.class);

	/**
	 * 
	 * 分页查询资源
	 * 
	 * @param params
	 * 
	 * @return
	 * 
	 */
	public PageInfo<Map> selectPage(Map params) {

		PageInfo<Map> page = dao.selectPage("resourcesMapper.queryResource", params);
		return page;
	}

	public List<Map> getResourceList(Map params) {
		return dao.selectList("resourcesMapper.queryResource", params);
	}

	public List<Map> getTreeResource(Map params) {
		List list = getResourceList(params);

		List rtList = TreeUtils.toTreeNodeList(list, Resources.class);

		ResultUtil.getSuccessResult(rtList);

		return rtList;
	}

	public List<Map> getResourceByUser(Map params) {
		return dao.selectList("resourcesMapper.getResourceByUser", params);
	}

}